package com.tanhua.model.vo;

import com.tanhua.model.domain.Announcement;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.BeanUtils;

import java.io.Serializable;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class AnnouncementVo implements Serializable {

    private String id;
    private String title; //标题
    private String description; //描述
    private String createDate; //创建时间

    public static AnnouncementVo init(Announcement announcement) {
        AnnouncementVo vo = new AnnouncementVo();
        if(announcement != null) {
            BeanUtils.copyProperties(announcement,vo);
            vo.setId(announcement.getId().toString());
            vo.setCreateDate(announcement.getCreated().toString());
        }
        return vo;
    }
}
